home *** CD-ROM | disk | FTP | other *** search
/ Freelog 115 / FreelogNo115-MaiJuin2013.iso / Internet / Filezilla Server / FileZilla_Server-0_9_41.exe / source / interface / misc / HyperLink.cpp < prev    next >
C/C++ Source or Header  |  2011-11-06  |  18KB  |  567 lines

  1. // HyperLink.cpp : implementation file
  2. //
  3. // HyperLink static control.
  4. //
  5. // Copyright (C) 1997, 1998 Giancarlo Iovino (giancarlo@saria.com)
  6. // All rights reserved. May not be sold for profit.
  7. //
  8. // This code is based on CHyperlink by Chris Maunder.
  9. // "GotoURL" function by Stuart Patterson appeared in the Aug, 1997
  10. // Windows Developer's Journal.
  11. // "Default hand cursor" from Paul DiLascia's Jan 1998 MSJ article.
  12.  
  13. #include <stdafx.h>
  14. #include "HyperLink.h"
  15.  
  16. #if defined(_DEBUG) && !defined(MMGR)
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21.  
  22. #define TOOLTIP_ID 1
  23.  
  24. #define SETBITS(dw, bits)    (dw |= bits)
  25. #define CLEARBITS(dw, bits)    (dw &= ~(bits))
  26. #define BITSET(dw, bit)        (((dw) & (bit)) != 0L)
  27.  
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CHyperLink
  30.  
  31. const DWORD CHyperLink::StyleUnderline         = 0x00000001;        // Underline bit
  32. const DWORD CHyperLink::StyleUseHover         = 0x00000002;        // Hand over coloring bit
  33. const DWORD CHyperLink::StyleAutoSize           = 0x00000004;        // Auto size bit
  34. const DWORD CHyperLink::StyleDownClick         = 0x00000008;        // Down click mode bit
  35. const DWORD CHyperLink::StyleGetFocusOnClick = 0x00000010;        // Get focus on click bit
  36. const DWORD CHyperLink::StyleNoHandCursor     = 0x00000020;        // No hand cursor bit
  37. const DWORD CHyperLink::StyleNoActiveColor     = 0x00000040;        // No active color bit
  38.  
  39. COLORREF CHyperLink::g_crLinkColor        = RGB(0, 0, 255);    // Blue
  40. COLORREF CHyperLink::g_crActiveColor    = RGB(0, 128, 128);    // Dark cyan
  41. COLORREF CHyperLink::g_crVisitedColor    = RGB(128, 0, 128);    // Purple
  42. COLORREF CHyperLink::g_crHoverColor        = RGB(255, 0, 0    );    // Red
  43. HCURSOR     CHyperLink::g_hLinkCursor        = NULL;                // No cursor
  44.  
  45. CHyperLink::CHyperLink()
  46. {
  47.     m_bOverControl        = FALSE;    // Cursor not yet over control
  48.     m_bVisited            = FALSE;    // Link has not been visited yet
  49.     m_bLinkActive        = FALSE;    // Control doesn't own the focus yet
  50.     m_strURL.Empty();                // Set URL to an empty string        
  51.     // Set default styles
  52.     m_dwStyle = StyleUnderline|StyleAutoSize|StyleGetFocusOnClick;
  53. }
  54.  
  55. CHyperLink::~CHyperLink()
  56. {
  57.     m_Font.DeleteObject();
  58. }
  59.  
  60. IMPLEMENT_DYNAMIC(CHyperLink, CStatic)
  61.  
  62. BEGIN_MESSAGE_MAP(CHyperLink, CStatic)
  63.     //{{AFX_MSG_MAP(CHyperLink)
  64.     ON_WM_CTLCOLOR_REFLECT()
  65.     ON_WM_SETCURSOR()
  66.     ON_WM_MOUSEMOVE()
  67.     ON_WM_LBUTTONUP()
  68.     ON_WM_SETFOCUS()
  69.     ON_WM_KILLFOCUS()
  70.     ON_WM_KEYDOWN()
  71.     ON_WM_NCHITTEST()
  72.     ON_WM_LBUTTONDOWN()    
  73.     //}}AFX_MSG_MAP
  74. END_MESSAGE_MAP()
  75.  
  76. /////////////////////////////////////////////////////////////////////////////
  77. // CHyperLink message handlers
  78.  
  79. BOOL CHyperLink::PreTranslateMessage(MSG* pMsg) 
  80. {
  81.     m_ToolTip.RelayEvent(pMsg);
  82.     return CStatic::PreTranslateMessage(pMsg);
  83. }
  84.  
  85. void CHyperLink::PreSubclassWindow() 
  86. {            
  87.     // If the URL string is empty try to set it to the window text
  88.     if (m_strURL.IsEmpty())
  89.         GetWindowText(m_strURL);
  90.  
  91.     // Check that the window text isn't empty.
  92.     // If it is, set it as URL string.
  93.     CString strWndText;
  94.     GetWindowText(strWndText);
  95.     if (strWndText.IsEmpty()) {
  96.         // Set the URL string as the window text
  97.         ASSERT(!m_strURL.IsEmpty());    // window text and URL both NULL!
  98.         CStatic::SetWindowText(m_strURL);
  99.     }
  100.  
  101.     // Get the current window font    
  102.     CFont* pFont = GetFont();    
  103.     
  104.     if (pFont != NULL) {
  105.         LOGFONT lf;
  106.         pFont->GetLogFont(&lf);
  107.         lf.lfUnderline = BITSET(m_dwStyle, StyleUnderline);
  108.         if (m_Font.CreateFontIndirect(&lf))
  109.             CStatic::SetFont(&m_Font);    
  110.         // Adjust window size to fit URL if necessary
  111.         AdjustWindow();
  112.     }
  113.     else {        
  114.         // if GetFont() returns NULL then probably the static
  115.         // control is not of a text type: it's better to set
  116.         // auto-resizing off
  117.         CLEARBITS(m_dwStyle,StyleAutoSize);
  118.     }
  119.     
  120.     if (!BITSET(m_dwStyle,StyleNoHandCursor))
  121.         SetDefaultCursor();      // Try to load an "hand" cursor
  122.  
  123.     // Create the tooltip
  124.     CRect rect; 
  125.     GetClientRect(rect);
  126.     m_ToolTip.Create(this);    
  127.  
  128.     m_ToolTip.AddTool(this, m_strURL, rect, TOOLTIP_ID);
  129.  
  130.     CStatic::PreSubclassWindow();
  131. }
  132.  
  133. // Handler for WM_CTLCOLOR reflected message (see message map)
  134. HBRUSH CHyperLink::CtlColor(CDC* pDC, UINT nCtlColor) 
  135. {        
  136.     ASSERT(nCtlColor == CTLCOLOR_STATIC);
  137.  
  138.     if (m_bOverControl && BITSET(m_dwStyle,StyleUseHover))
  139.         pDC->SetTextColor(g_crHoverColor);
  140.     else if (!BITSET(m_dwStyle,StyleNoActiveColor) && m_bLinkActive)
  141.         pDC->SetTextColor(g_crActiveColor);
  142.     else if (m_bVisited)
  143.         pDC->SetTextColor(g_crVisitedColor);
  144.     else
  145.         pDC->SetTextColor(g_crLinkColor);
  146.  
  147.     // Set transparent drawing mode
  148.     pDC->SetBkMode(TRANSPARENT);
  149.     return (HBRUSH)GetStockObject(NULL_BRUSH);
  150. }
  151.  
  152. void CHyperLink::OnMouseMove(UINT nFlags, CPoint point) 
  153. {
  154.  
  155.     if (m_bOverControl)        // Cursor currently over control
  156.     {
  157.         CRect rect;
  158.         GetClientRect(rect);
  159.  
  160.         if (!rect.PtInRect(point))
  161.         {
  162.             m_bOverControl = FALSE;
  163.             ReleaseCapture();
  164.             Invalidate();                        
  165.             return;
  166.         }            
  167.     }
  168.     else                      // Cursor has left control area
  169.     {
  170.         m_bOverControl = TRUE;
  171.         Invalidate();        
  172.         SetCapture();        
  173.     }
  174. }
  175.  
  176. //////////////////////////////////////////////////////////////////////////
  177. // "Normally, a static control does not get mouse events unless it has
  178. // SS_NOTIFY. This achieves the same effect as SS_NOTIFY, but it's fewer
  179. // lines of code and more reliable than turning on SS_NOTIFY in OnCtlColor
  180. // because Windows doesn't send WM_CTLCOLOR to bitmap static controls."
  181. // (Paul DiLascia)
  182. LRESULT CHyperLink::OnNcHitTest(CPoint /*point*/) 
  183. {
  184.         return HTCLIENT;    
  185. }
  186.  
  187. void CHyperLink::OnLButtonDown(UINT /*nFlags*/, CPoint /*point*/) 
  188. {
  189.     if (BITSET(m_dwStyle,StyleGetFocusOnClick))
  190.         SetFocus();                // Set the focus and make the link active
  191.     if (BITSET(m_dwStyle,StyleDownClick))
  192.         FollowLink();
  193.     m_bLinkActive = TRUE;
  194. }
  195.  
  196. void CHyperLink::OnLButtonUp(UINT /*nFlags*/, CPoint /*point*/) 
  197. {
  198.     if (m_bLinkActive && !BITSET(m_dwStyle,StyleDownClick))
  199.         FollowLink();
  200. }
  201.  
  202. BOOL CHyperLink::OnSetCursor(CWnd* /*pWnd*/, UINT /*nHitTest*/, UINT /*message*/) 
  203. {    
  204.     if (g_hLinkCursor)
  205.     {
  206.         ::SetCursor(g_hLinkCursor);
  207.         return TRUE;
  208.     }
  209.     return FALSE;
  210. }
  211.  
  212. void CHyperLink::OnSetFocus(CWnd* /*pOldWnd*/) 
  213. {
  214.     m_bLinkActive = TRUE;
  215.     Invalidate();                            // Repaint to set the focus
  216. }
  217.  
  218. void CHyperLink::OnKillFocus(CWnd* /*pNewWnd*/) 
  219. {    
  220.     // Assume that control lost focus = mouse out
  221.     // this avoid troubles with the Hover color
  222.     m_bOverControl = FALSE;
  223.     m_bLinkActive = FALSE;
  224.     Invalidate();                            // Repaint to unset the focus
  225. }
  226.  
  227. void CHyperLink::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
  228. {    
  229.     if (nChar == VK_SPACE)
  230.         FollowLink();
  231.     else
  232.         CStatic::OnKeyDown(nChar, nRepCnt, nFlags);
  233. }
  234.  
  235. /////////////////////////////////////////////////////////////////////////////
  236. // CHyperLink operations
  237.  
  238. void CHyperLink::SetColors(    COLORREF crLinkColor,
  239.                             COLORREF crActiveColor,
  240.                             COLORREF crVisitedColor,
  241.                             COLORREF crHoverColor /* = -1 */) 
  242. {
  243.     g_crLinkColor    = crLinkColor;
  244.     g_crActiveColor     = crActiveColor;
  245.     g_crVisitedColor = crVisitedColor;    
  246.  
  247.     if (crHoverColor == -1)
  248.         g_crHoverColor = ::GetSysColor(COLOR_HIGHLIGHT);
  249.     else
  250.         g_crHoverColor = crHoverColor;    
  251. }
  252.  
  253. void CHyperLink::SetColors(HYPERLINKCOLORS& linkColors) {
  254.     g_crLinkColor     = linkColors.crLink;
  255.     g_crActiveColor     = linkColors.crActive;
  256.     g_crVisitedColor = linkColors.crVisited;
  257.     g_crHoverColor     = linkColors.crHover;
  258. }
  259.  
  260. void CHyperLink::GetColors(HYPERLINKCOLORS& linkColors) {
  261.     linkColors.crLink = g_crLinkColor;
  262.     linkColors.crActive = g_crActiveColor;
  263.     linkColors.crVisited = g_crVisitedColor;
  264.     linkColors.crHover = g_crHoverColor;
  265. }
  266.  
  267. void CHyperLink::SetLinkCursor(HCURSOR hCursor) {
  268.     ASSERT(hCursor != NULL);
  269.  
  270.     g_hLinkCursor = hCursor;
  271.     if (g_hLinkCursor == NULL)
  272.         SetDefaultCursor();
  273. }
  274.  
  275. HCURSOR CHyperLink::GetLinkCursor() {
  276.     return g_hLinkCursor;
  277. }
  278.  
  279. BOOL CHyperLink:: ModifyLinkStyle(DWORD dwRemove, DWORD dwAdd,
  280.                                   BOOL bApply /* =TRUE */)
  281. {
  282.     // Check if we are adding and removing the same style
  283.     if ((dwRemove & dwAdd) != 0L)
  284.         return FALSE;
  285.  
  286.     // Remove old styles and set the new ones
  287.     CLEARBITS(m_dwStyle, dwRemove);
  288.     SETBITS(m_dwStyle, dwAdd);
  289.         
  290.     if (bApply && ::IsWindow(GetSafeHwnd())) {
  291.         // If possible, APPLY the new styles on the fly
  292.         if (BITSET(dwAdd,StyleUnderline) || BITSET(dwRemove,StyleUnderline))
  293.             SwitchUnderline();        
  294.         if (BITSET(dwAdd,StyleAutoSize))
  295.             AdjustWindow();        
  296.         if (BITSET(dwRemove,StyleUseHover))
  297.             Invalidate();
  298.     }
  299.     return TRUE;
  300. }
  301.  
  302. DWORD CHyperLink::GetLinkStyle() const {
  303.     return m_dwStyle;
  304. }
  305.  
  306. void CHyperLink::SetURL(CString strURL)
  307. {
  308.     m_strURL = strURL;
  309.  
  310.     if (::IsWindow(GetSafeHwnd())) {
  311.         ShowWindow(SW_HIDE);
  312.         AdjustWindow();
  313.         m_ToolTip.UpdateTipText(strURL, this, TOOLTIP_ID);
  314.         ShowWindow(SW_SHOW);
  315.     }
  316. }
  317.  
  318. CString CHyperLink::GetURL() const { 
  319.     return m_strURL;   
  320. }
  321.  
  322. void CHyperLink::SetWindowText(LPCTSTR lpszText)
  323. {
  324.     ASSERT(lpszText != NULL);
  325.  
  326.     if (::IsWindow(GetSafeHwnd())) {
  327.         // Set the window text and adjust its size while the window
  328.         // is kept hidden in order to allow dynamic modification
  329.         ShowWindow(SW_HIDE);                // Hide window
  330.         // Call the base class SetWindowText()
  331.         CStatic::SetWindowText(lpszText);
  332.         // Resize the control if necessary
  333.         AdjustWindow();
  334.         ShowWindow(SW_SHOW);                // Show window
  335.     }
  336. }
  337.  
  338. void CHyperLink::SetFont(CFont* pFont)
  339. {
  340.     ASSERT(::IsWindow(GetSafeHwnd()));
  341.     ASSERT(pFont != NULL);
  342.     
  343.     // Set the window font and adjust its size while the window
  344.     // is kept hidden in order to allow dynamic modification
  345.     ShowWindow(SW_HIDE);                // Hide window
  346.     LOGFONT lf;
  347.     // Create the new font
  348.     pFont->GetLogFont(&lf);
  349.     m_Font.DeleteObject();
  350.     m_Font.CreateFontIndirect(&lf);
  351.     // Call the base class SetFont()
  352.     CStatic::SetFont(&m_Font);
  353.     // Resize the control if necessary
  354.     AdjustWindow();
  355.     ShowWindow(SW_SHOW);                // Show window    
  356. }
  357.  
  358. // Function to set underline on/off
  359. void CHyperLink::SwitchUnderline()
  360. {    
  361.     LOGFONT lf;
  362.     CFont* pFont = GetFont();
  363.     if (pFont != NULL) {
  364.         pFont->GetLogFont(&lf);        
  365.         lf.lfUnderline = BITSET(m_dwStyle,StyleUnderline);
  366.         m_Font.DeleteObject();
  367.         m_Font.CreateFontIndirect(&lf);
  368.         SetFont(&m_Font);                    
  369.     }    
  370. }
  371.  
  372. // Move and resize the window so that its client area has the same size
  373. // as the hyperlink text. This prevents the hyperlink cursor being active
  374. // when it is not over the text.
  375. void CHyperLink::AdjustWindow()
  376. {    
  377.     ASSERT(::IsWindow(GetSafeHwnd()));
  378.     
  379.     if (!BITSET(m_dwStyle,StyleAutoSize)) 
  380.         return;
  381.  
  382.     // Get the current window rect
  383.     CRect rcWnd;
  384.     GetWindowRect(rcWnd);
  385.  
  386.     // For a child CWnd object, window rect is relative to the 
  387.     // upper-left corner of the parent windowÆs client area. 
  388.     CWnd* pParent = GetParent();
  389.     if (pParent)
  390.         pParent->ScreenToClient(rcWnd);
  391.     
  392.     // Get the current client rect
  393.     CRect rcClient;
  394.     GetClientRect(rcClient);
  395.  
  396.     // Calc border size based on window and client rects
  397.     int borderWidth = rcWnd.Width() - rcClient.Width();
  398.     int borderHeight = rcWnd.Height() - rcClient.Height();
  399.  
  400.     // Get the extent of window text 
  401.     CString strWndText;
  402.     GetWindowText(strWndText);
  403.     
  404.     CDC* pDC = GetDC();    
  405.     CFont* pOldFont = pDC->SelectObject(&m_Font);
  406.     CSize Extent = pDC->GetTextExtent(strWndText);
  407.     pDC->SelectObject(pOldFont);
  408.     ReleaseDC(pDC);
  409.  
  410.     // Get the text justification style
  411.     DWORD dwStyle = GetStyle();
  412.  
  413.     // Recalc window size and position based on text justification
  414.     if (BITSET(dwStyle, SS_CENTERIMAGE))
  415.         rcWnd.DeflateRect(0, (rcWnd.Height() - Extent.cy) / 2);
  416.     else
  417.         rcWnd.bottom = rcWnd.top + Extent.cy;
  418.  
  419.     if (BITSET(dwStyle, SS_CENTER))
  420.         rcWnd.DeflateRect((rcWnd.Width() - Extent.cx) / 2, 0);
  421.     else if (BITSET(dwStyle,SS_RIGHT))
  422.         rcWnd.left  = rcWnd.right - Extent.cx;
  423.     else // SS_LEFT
  424.         rcWnd.right = rcWnd.left + Extent.cx;
  425.  
  426.     // Move and resize the window
  427.     MoveWindow(rcWnd.left, rcWnd.top, rcWnd.Width() + borderWidth,
  428.         rcWnd.Height() + borderHeight);
  429. }
  430.  
  431. void CHyperLink::SetVisited(BOOL bVisited /* = TRUE */) {
  432.     m_bVisited = bVisited;
  433. }
  434.  
  435. BOOL CHyperLink::IsVisited() const {
  436.     return m_bVisited;
  437. }
  438.  
  439. /////////////////////////////////////////////////////////////////////////////
  440. // CHyperLink implementation
  441.  
  442. // The following function appeared in Paul DiLascia's Jan 1998 
  443. // MSJ articles. It loads a "hand" cursor from "winhlp32.exe"
  444. // resources
  445. void CHyperLink::SetDefaultCursor()
  446. {
  447.     if (g_hLinkCursor == NULL)        // No cursor handle - load our own
  448.     {
  449.         // Get the windows directory
  450.         CString strWndDir;
  451.         GetWindowsDirectory(strWndDir.GetBuffer(MAX_PATH), MAX_PATH);
  452.         strWndDir.ReleaseBuffer();
  453.  
  454.         strWndDir += _T("\\winhlp32.exe");
  455.         // This retrieves cursor #106 from winhlp32.exe, which is a hand pointer
  456.         HMODULE hModule = LoadLibrary(strWndDir);
  457.         if (hModule) {
  458.             HCURSOR hHandCursor = ::LoadCursor(hModule, MAKEINTRESOURCE(106));
  459.             if (hHandCursor)
  460.                 g_hLinkCursor = CopyCursor(hHandCursor);
  461.             FreeLibrary(hModule);
  462.         }
  463.     }
  464. }
  465.  
  466. LONG CHyperLink::GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata)
  467. {
  468.     HKEY hkey;
  469.     LONG retval = RegOpenKeyEx(key, subkey, 0, KEY_QUERY_VALUE, &hkey);
  470.  
  471.     if (retval == ERROR_SUCCESS) {
  472.         long datasize = MAX_PATH;
  473.         TCHAR data[MAX_PATH];
  474.         RegQueryValue(hkey, NULL, data, &datasize);
  475.         lstrcpy(retdata,data);
  476.         RegCloseKey(hkey);
  477.     }
  478.  
  479.     return retval;
  480. }
  481.  
  482. // Error report function
  483. void CHyperLink::ReportError(int nError)
  484. {
  485.     CString str;
  486.    
  487.     switch (nError) {
  488.         case 0:                       str = _T("The operating system is out\nof memory or resources."); break;
  489.         case ERROR_FILE_NOT_FOUND:    str = _T("The specified file was not found."); break;
  490.         case ERROR_PATH_NOT_FOUND:      str = _T("The specified path was not found."); break;    
  491.         case ERROR_BAD_FORMAT:        str = _T("The .EXE file is invalid\n(non-Win32 .EXE or error in .EXE image)."); break;
  492.         case SE_ERR_ACCESSDENIED:     str = _T("The operating system denied\naccess to the specified file."); break;
  493.         case SE_ERR_ASSOCINCOMPLETE:  str = _T("The filename association is\nincomplete or invalid."); break;
  494.         case SE_ERR_DDEBUSY:          str = _T("The DDE transaction could not\nbe completed because other DDE transactions\nwere being processed."); break;
  495.         case SE_ERR_DDEFAIL:          str = _T("The DDE transaction failed."); break;
  496.         case SE_ERR_DDETIMEOUT:       str = _T("The DDE transaction could not\nbe completed because the request timed out."); break;
  497.         case SE_ERR_DLLNOTFOUND:      str = _T("The specified dynamic-link library was not found."); break;
  498.         //case SE_ERR_FNF:              str = _T("Windows 95 only: The specified file was not found."); break; 
  499.         case SE_ERR_NOASSOC:          str = _T("There is no application associated\nwith the given filename extension."); break;
  500.         case SE_ERR_OOM:              str = _T("There was not enough memory to complete the operation."); break;
  501.         //case SE_ERR_PNF:              str = _T("The specified path was not found."); break;
  502.         case SE_ERR_SHARE:            str = _T("A sharing violation occurred. "); break;
  503.         default:                      str.Format(_T("Unknown Error (%d) occurred."), nError); break;
  504.     }
  505.  
  506.     str = "Can't open link:\n\n" + str;
  507.     AfxMessageBox(str, MB_ICONEXCLAMATION | MB_OK);
  508. }
  509.  
  510. // "GotoURL" function by Stuart Patterson
  511. // As seen in the August, 1997 Windows Developer's Journal.
  512. HINSTANCE CHyperLink::GotoURL(LPCTSTR url, int showcmd)
  513. {
  514.     USES_CONVERSION;
  515.  
  516.     TCHAR key[MAX_PATH + MAX_PATH];    
  517.  
  518.     // First try ShellExecute()
  519.     HINSTANCE result = ShellExecute(NULL, _T("open"), url, NULL,NULL, showcmd);
  520.  
  521.     // If it failed, get the .htm regkey and lookup the program
  522.     if ((UINT)result <= HINSTANCE_ERROR) {        
  523.         
  524.         if (GetRegKey(HKEY_CLASSES_ROOT, _T(".htm"), key) == ERROR_SUCCESS) {
  525.             lstrcat(key, _T("\\shell\\open\\command"));
  526.  
  527.             if (GetRegKey(HKEY_CLASSES_ROOT,key,key) == ERROR_SUCCESS) {
  528.                 TCHAR *pos;
  529.                 pos = _tcsstr(key, _T("\"%1\""));
  530.                 if (pos == NULL) {                     // No quotes found
  531.                     pos = _tcsstr(key, _T("%1"));       // Check for %1, without quotes
  532.                     if (pos == NULL)                   // No parameter at all...
  533.                         pos = key+lstrlen(key) - 1;
  534.                     else
  535.                         *pos = '\0';                   // Remove the parameter
  536.                 }
  537.                 else
  538.                     *pos = '\0';                       // Remove the parameter
  539.  
  540.                 lstrcat(pos, _T(" "));
  541.                 lstrcat(pos, url);
  542.                 result = (HINSTANCE)WinExec(T2A(key), showcmd);
  543.                 PROCESS_INFORMATION ProcessInformation;  
  544.                 STARTUPINFO startupinfo;
  545.                 memset(&startupinfo, 0, sizeof(startupinfo));
  546.                 startupinfo.cb = sizeof(startupinfo);        
  547.                 CreateProcess(0, key, 0, 0, 0, 0, 0, 0, &startupinfo, &ProcessInformation);
  548.             }
  549.         }
  550.     }
  551.       
  552.     return result;
  553. }
  554.  
  555. // Activate the link
  556. void CHyperLink::FollowLink() 
  557. {    
  558.     int result = (int) GotoURL(m_strURL, SW_SHOW);
  559.     if (result <= HINSTANCE_ERROR) {
  560.         MessageBeep(MB_ICONEXCLAMATION);    // Unable to follow link
  561.         ReportError(result);
  562.     } else {
  563.         // Mark link as visited and repaint window
  564.         m_bVisited = TRUE;        
  565.         Invalidate();
  566.     }
  567. }